package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.HTTPStatusEvent;
	import flash.events.IOErrorEvent;
	import flash.events.ProgressEvent;
	import flash.events.SecurityErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;
	
	public class UrlEvent extends Sprite
	{
		public function UrlEvent()
		{
			var loader:URLLoader = new URLLoader(new URLRequest("https://www.flash.cn/cdm/latest/flashplayerpp_install_cn.exe"));
			loader.dataFormat = URLLoaderDataFormat.VARIABLES;
			
			loader.addEventListener(Event.OPEN, onOpen);
			loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatus);
			loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
			loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityErrot);
			loader.addEventListener(ProgressEvent.PROGRESS, onProgress);
			loader.addEventListener(Event.COMPLETE, onComplete);
		}
		
		private function onOpen(event:Event):void
		{
			trace("提示：开始下载");
		}
		
		private function onComplete(event:Event):void
		{
			trace("加载完成");
			var loader:URLLoader = event.target as URLLoader;
			for(var str:String in loader.data)
			{
				trace(str + ":" + loader.data);
			}
		}
		
		private function onProgress(event:ProgressEvent):void
		{
			trace("加载中....");
		}
		
		private function onHttpStatus(event:HTTPStatusEvent):void
		{
			trace("提示：http请求状态代码：" + event.status);
		}
		
		private function onIOError(event:IOErrorEvent):void
		{
			trace("提示：致命错误导致下载终止");
		}
		
		private function onSecurityErrot(event:SecurityErrorEvent):void
		{
			trace("提示：试图读取安全沙漏允许以外的域数据");
		}
	}
}